unit MainForm;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, uCEFWindowParent, uCEFChromium,
  Vcl.Buttons, Vcl.StdCtrls, Vcl.ExtCtrls, uCEFApplication;

type
  TForm2 = class(TForm)
    chrm: TChromium;
    cfwndwprnt1: TCEFWindowParent;
    pnlTop: TPanel;
    lbledtUrl: TLabeledEdit;
    btnGo: TButton;
    procedure btnGoClick(Sender: TObject);
    procedure lbledtUrlKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

  procedure CreateGlobalCEFApp;

implementation

{$R *.dfm}
procedure CreateGlobalCEFApp;
begin
  GlobalCEFApp                          := TCefApplication.Create;
end;

procedure TForm2.btnGoClick(Sender: TObject);
begin
  chrm.LoadURL(lbledtUrl.Text);
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
  lbledtUrl.Text := ExtractFilePath(ParamStr(0)) + 'test.html';
end;

procedure TForm2.FormShow(Sender: TObject);
begin
  if not(chrm.CreateBrowser(cfwndwprnt1, '')) then
    chrm.CreateBrowser(cfwndwprnt1, '')
end;

procedure TForm2.lbledtUrlKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_RETURN then
    btnGo.Click;
end;

end.
